package cms.manage.template.value.impl;

import cms.bean.membershipCard.MembershipCard;
import cms.bean.template.Forum;
import cms.manage.template.impl.MembershipCardTemplateManage;
import cms.manage.template.value.TplValueStrategy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

import static cms.common.SystemConstant.DisplayType.DISPLAY_COLLECTION;
import static cms.common.SystemConstant.DisplayType.DISPLAY_ENTITYBEAN;

@Service("会员卡")
public class MembershipCardStrategy implements TplValueStrategy {
    @Resource
    MembershipCardTemplateManage membershipCardTemplateManage;// 会员卡 -- 模板方法实现

    @Override
    public Object doOperation(Forum forum, Map submitParameter, Map runtimeParameter) {
        if(forum.getForumChildType().equals("会员卡列表")){
            if(forum.getDisplayType().equals(DISPLAY_COLLECTION.getValue())){//集合
                List<MembershipCard> value = membershipCardTemplateManage.membershipCardCollection(forum,submitParameter, runtimeParameter);
                return value;
            }
        }else if(forum.getForumChildType().equals("会员卡内容")){
            if(forum.getDisplayType().equals(DISPLAY_ENTITYBEAN.getValue())){//实体对象
                MembershipCard value =  membershipCardTemplateManage.membershipCardContentEntityBean(forum, submitParameter, runtimeParameter);
                return value;
            }
        }else if(forum.getForumChildType().equals("购买会员卡")){
            if(forum.getDisplayType().equals(DISPLAY_COLLECTION.getValue())){//集合
                Map<String,Object> value = membershipCardTemplateManage.buyMembershipCardCollection(forum, submitParameter, runtimeParameter);
                return value;
            }
        }
        return null;
    }
}
